﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Restaurant.BusinessEntity;

namespace Restaurant.Repository.Mapping
{
    public class PlatoMap : EntityTypeConfiguration<Plato>
    {
        public PlatoMap()
        {
            this.HasKey(r => r.Id);

            //propiedades
            this.Property(r => r.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(r => r.Nombre)
                .IsRequired().HasMaxLength(20);

            this.Property(r => r.Precio).IsRequired();

            //table
            this.ToTable("Plato");

            //Relaciones
            this.HasRequired(r => r.Categoria)
                .WithMany(r=>r.Platos)
                .HasForeignKey(r => r.IdCategoria)
                .WillCascadeOnDelete(false);
        }


    }
}
